/*
 * Copyright (c) 2024 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

#ifndef MOCK_NRF_RPC_TRANSPORT_H_
#define MOCK_NRF_RPC_TRANSPORT_H_

#include <nrf_rpc.h>
#include <nrf_rpc_tr.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @defgroup mock_nrf_rpc_transport Mock nRF RPC transport
 * @brief Mock nRF RPC transport for unit testing.
 *
 * @{
 */

/** @brief Mock nRF RPC transport object. */
extern const struct nrf_rpc_tr mock_nrf_rpc_tr;

/** @brief nRF RPC packet content. */
typedef struct mock_nrf_rpc_pkt {
	const uint8_t *data;
	size_t len;
} mock_nrf_rpc_pkt_t;

/**
 * @brief Registers an expected nRF RPC packet.
 *
 * This function queues the content of the next nRF RPC packet that is expected to be
 * generated by the nRF RPC core and sent to the nRF RPC mock transport.
 *
 * When the mock transport receives an nRF RPC packet destined for the remote node,
 * it checks that the packet's content matches the next queued expected packet in its
 * internal list. If the contents do not match, the function triggers a test error.
 * If a response has been defined for the expected packet, the mock transport will
 * send this response back to the nRF RPC core.
 */
void mock_nrf_rpc_tr_expect_add(mock_nrf_rpc_pkt_t expect, mock_nrf_rpc_pkt_t response);

/**
 * @brief Ensures all expected nRF RPC packets have been sent.
 *
 * This function checks if all expected nRF RPC packets have been dispatched within the
 * mock nRF RPC transport. It verifies that there are no remaining expected packets that
 * have not been sent. If there are any unsent expected packets, a test error is raised.
 */
void mock_nrf_rpc_tr_expect_done(void);

/**
 * @brief Clears the list of expected nRF RPC packets.
 */
void mock_nrf_rpc_tr_expect_reset(void);

/**
 * @brief Simulates an nRF RPC packet reception from the remote node.
 */
void mock_nrf_rpc_tr_receive(mock_nrf_rpc_pkt_t packet);

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif /* MOCK_NRF_RPC_TRANSPORT_H_ */
